package cn.ac.aircas.system.domain;

import java.io.Serializable;
import java.math.BigDecimal;

import cn.ac.aircas.common.core.domain.BaseEntity;
import com.opencsv.bean.CsvBindByPosition;
import lombok.Data;

import javax.validation.constraints.Pattern;

/**
 * 
 * @TableName t_region
 */
@Data
public class SysRegion extends BaseEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * id
     */
    @CsvBindByPosition(position = 0)
    @Pattern(regexp = "^[1-9]\\d*$", message = "id必须为正整数")
    private Integer id;

    /**
     * 父id
     */
    @Pattern(regexp = "^[1-9]\\d*$", message = "pid必须为正整数")
    @CsvBindByPosition(position = 1)
    private Integer pid;

    /**
     * 层级
     */
    @CsvBindByPosition(position = 2)
    private Integer deep;

    /**
     * 名称
     */
    @CsvBindByPosition(position = 3)
    private String name;

    /**
     * 拼音前缀
     */
    private String pinyinPrefix;

    /**
     * 拼音
     */
    private String pinyin;

    /**
     * 
     */
    private String extId;

    @CsvBindByPosition(position = 4)
    private String extPath;

    /**
     * 全称
     */
    private String extName;

    /**
     * 
     */
    private BigDecimal latitude;

    /**
     * 
     */
    private BigDecimal longitude;

    /**
     * 中心点
     */
    @CsvBindByPosition(position = 5)
    private String geo;

    /**
     * 边界线
     */
    @CsvBindByPosition(position = 6)
    private String polygon;

    private String status;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        SysRegion other = (SysRegion) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getPid() == null ? other.getPid() == null : this.getPid().equals(other.getPid()))
            && (this.getDeep() == null ? other.getDeep() == null : this.getDeep().equals(other.getDeep()))
            && (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
            && (this.getPinyinPrefix() == null ? other.getPinyinPrefix() == null : this.getPinyinPrefix().equals(other.getPinyinPrefix()))
            && (this.getPinyin() == null ? other.getPinyin() == null : this.getPinyin().equals(other.getPinyin()))
            && (this.getExtId() == null ? other.getExtId() == null : this.getExtId().equals(other.getExtId()))
            && (this.getExtName() == null ? other.getExtName() == null : this.getExtName().equals(other.getExtName()))
            && (this.getLatitude() == null ? other.getLatitude() == null : this.getLatitude().equals(other.getLatitude()))
            && (this.getLongitude() == null ? other.getLongitude() == null : this.getLongitude().equals(other.getLongitude()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getPid() == null) ? 0 : getPid().hashCode());
        result = prime * result + ((getDeep() == null) ? 0 : getDeep().hashCode());
        result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
        result = prime * result + ((getPinyinPrefix() == null) ? 0 : getPinyinPrefix().hashCode());
        result = prime * result + ((getPinyin() == null) ? 0 : getPinyin().hashCode());
        result = prime * result + ((getExtId() == null) ? 0 : getExtId().hashCode());
        result = prime * result + ((getExtName() == null) ? 0 : getExtName().hashCode());
        result = prime * result + ((getLatitude() == null) ? 0 : getLatitude().hashCode());
        result = prime * result + ((getLongitude() == null) ? 0 : getLongitude().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", pid=").append(pid);
        sb.append(", deep=").append(deep);
        sb.append(", name=").append(name);
        sb.append(", pinyinPrefix=").append(pinyinPrefix);
        sb.append(", pinyin=").append(pinyin);
        sb.append(", extId=").append(extId);
        sb.append(", extName=").append(extName);
        sb.append(", latitude=").append(latitude);
        sb.append(", longitude=").append(longitude);
        sb.append("]");
        return sb.toString();
    }
}